package com.ctu.study
{
	public class UintProperty extends Property
	{
		public function UintProperty(name:String,value:uint)
		{
			super(name, value);
		}
		
		override public function setHelper(obj1:Object,obj2:Object):Object
		{
			if(obj2==null)
			{
				return obj2;
			}
			
			var _uint:uint = (obj2 is String )? valueFromString(String(obj2)) as uint : uint(obj2);
			
			return _uint;
		}
		
		override public function valueFromString(value:String):Object
		{
			if(value.substr(0,1)=="#")
			{
				value = "0x"+value.substr(1, value.length -1);
			}
			
			if(value.toLowerCase().substr(0,2) == "0x")
			{
				return uint(value);
			}
						
			return 0;
			
		}
		
		override public function toXMLString(obj:Object):String
		{
			return "0x"+obj.toString(16);
		}
		
		override public function hash(obj:Object, code:uint):uint
		{
			return UintProperty.doHash(obj as uint, code);
		}
		
		public static function doHash(first:uint, second:uint):uint
		{
			return (first << 5) ^ (second >> 27)
		}
	}
}